const mysql = require('mysql');
const db = require('../config/db')
//创建链接对象
const connection = mysql.createConnection(db.options);;''

//开始连接
connection.connect();

//执行sql语句
const execSQL = (sql) => {
    const promise = new Promise((resolve, reject) => {
        const res = connection.query(sql, (err, res) => {
            if (err) {
                reject(err);
                return;
            }
            resolve(res);
        });    
    })
    return promise; 
} 

module.exports = {
    execSQL
}

